package com.zhuoyue.system.service.impl;

import com.zhuoyue.common.annotation.DataScope;
import com.zhuoyue.system.domain.po.FingerPrintPo;
import com.zhuoyue.system.domain.vo.FingerPrintVo;
import com.zhuoyue.system.mapper.TblFingerPrintMapper;
import com.zhuoyue.system.service.ITblFingerPrintService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zhanghui
 * @date 2021/9/24 15:18
 */
@Service
public class TblFingerPrintServiceImpl implements ITblFingerPrintService {
    @Autowired
    private TblFingerPrintMapper fingerPrintMapper;

    @DataScope(deptAlias = "s_d")
    @Override
    public List<FingerPrintVo> listFingerPrint(FingerPrintPo fingerPrintPo) {
        List<FingerPrintVo> fingerPrintVos = fingerPrintMapper.listFingerPrint(fingerPrintPo);
        for (FingerPrintVo fingerPrintVo : fingerPrintVos) {
            fingerPrintVo.setFingerPrintType(getPrintType(fingerPrintVo.getDeviceType(), fingerPrintVo.getFingerPrintType()));
        }
        return fingerPrintVos;
    }

    @Override
    public Integer deleteFingerPrint(String id) {
        return fingerPrintMapper.deleteFingerPrint(id);
    }

    private String getPrintType(String deviceType, String fingerPrintType) {
        String type = "普通指纹";
        switch (deviceType) {
            case "FABE0202":
            case "FABE0203":
                switch (fingerPrintType) {
                    case "01":
                        type = "管理员指纹";
                        break;
                    case "03":
                        type = "客人指纹";
                        break;
                    case "04":
                        type = "挟持指纹";
                        break;
                    default:
                        break;
                }
                break;
            case "0FBF0202":
                switch (fingerPrintType) {
                    case "01":
                        type = "管理员指纹";
                        break;
                    case "03":
                        type = "挟持指纹";
                        break;
                    case "04":
                        type = "临时指纹";
                        break;
                    default:
                        break;
                }
                break;
            default:
                break;
        }

        return type;
    }
}
